using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;

namespace WebUtils.Controls
{
    public class visorDeReportes
    {
        public string selectionFormula="";
        public ReportClass archivoReporte;
        public string paradescript="";
        public string paravalor="";

        public void verReporte(System.Web.UI.Page page)
        {
            if (archivoReporte == null)
                throw new ArgumentException("por favor escriva el nombre del archivo de reporte");

            page.Session["rptSeleccionFormula"] = selectionFormula;
            page.Session["urlReport"] = archivoReporte;

            if (paradescript != "")
            {
                paradescript = paradescript + ",empresa,direccion,telefono,mail";
            }
            else
            {
                paradescript = "empresa,direccion,telefono,mail";
            }
            if (paravalor != "")
            {

                paravalor = paravalor + "," + System.Configuration.ConfigurationManager.AppSettings["empresa"] + "," 
                    + System.Configuration.ConfigurationManager.AppSettings["direccion"] + "," 
                    + System.Configuration.ConfigurationManager.AppSettings["telefono"] + "," +
                    System.Configuration.ConfigurationManager.AppSettings["mail"];
            }
            else
            {
                paravalor = System.Configuration.ConfigurationManager.AppSettings["empresa"] +
                    "," + System.Configuration.ConfigurationManager.AppSettings["direccion"] + "," 
                    + System.Configuration.ConfigurationManager.AppSettings["telefono"] + "," 
                    + System.Configuration.ConfigurationManager.AppSettings["mail"];
            }
            page.Session["paraDescript"] = paradescript;
            page.Session["paravalor"] = paravalor;
            string strparam;
            string url = Tecnopez.Globals.Functions.getHost(page) + "controls/visorReportes.aspx";
            strparam = " width= 800,height= 600, scrollbars=yes, resizable=yes, top=0,left=0,status=yes ";
            page.Response.Write("<script>window.open('" + url + "','Reporte', '" + strparam + "');</script>");



        }
    }

}
